- /* ceilpow2.cpp by K.Tsuru */
- // function ID = 001
- /*********************************************************************************
- SN library sub-function
- Return a value k which satisfies a condition sz<=k (k = 2^n).
- If sz*2 > UINT_MAX=4294967295(32 bits system),
- return a value INT_MAX+1 = 2147483648L = 2^31.
- **********************************************************************************/
- #include <limits.h>
-
- unsigned int ceilpow2(unsigned int sz){
- if(sz < 2u) return 1u;
- if(sz > UINT_MAX/2u) return (unsigned int)INT_MAX+1u;
-
- unsigned int k = 2u;
-
- while(k < sz) k *= 2u;
- return k;
- }
ceilpow2.cpp : last modifiled at 2017/02/17 10:34:24(623 bytes)
created at 2016/04/11 11:17:20
The creation time of this html file is 2017/10/07 10:54:15 (Sat Oct 07 10:54:15 2017).